<template>
  <div class="home h100">
    <main>
      <router-view/>
    </main>

    <footer>
      <router-link v-for="(item, index) in list" 
                   active-class="active"
                   tag="span" :to="item.path" :key="index">
                   <span v-show="item.path === '/home/car' && $store.getters.allCount > 0" class="span">
                     {{ $store.getters.allCount }}
                   </span>
        {{ item.title }}
      </router-link>
    </footer>
  </div>
</template>

<script>

export default {
  name: 'Home',
  data() {
    return {
      list: [
        {
          path: "/home/classify",
          title: "分类"
        },
        {
          path: "/home/car",
          title: "购物车"
        },
        {
          path: "/home/my",
          title: "我的"
        }
      ]
    }
  },
  created() {
    console.log(this.$store.getters)
  }
}
</script>

<style scoped>
.home {
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

footer{
  height: 46px;
  line-height: 46px;
  text-align: center;
  display: flex;
}

footer > span {
  flex: 1;
  position: relative;
}

.span {
  position: absolute;
  top: 5px;
  right: 20px;
  display: inline-block;
  width: 20px;
  height: 20px;
  line-height: 20px;
  font-size: 12px;
  border-radius: 50%;
  background: orangered;
  color: #fff !important;
}
</style>
